package tx.yt.charge.utils;

import tx.yt.charge.model.UserInfo;

import javax.servlet.http.HttpServletRequest;

/**
 * @author: chenmiao@hupu.com
 * Date: 2015-1-8
 */
public class SessionUtil {

    /**
     * 根据seesion判断是否登陆
     * @param request
     * @return
     */
    public static boolean isLogin(HttpServletRequest request){
        Object loginSe = request.getSession().getAttribute("userInfo");
        return ((null != loginSe) && loginSe.getClass().isAssignableFrom(UserInfo.class)) ? true : false;
    }

    public static void setLoginFlag(HttpServletRequest request,UserInfo userInfo){
        request.getSession().setAttribute("userInfo",userInfo);
    }

}
